package main

import (
	"fmt"
	bank "gopl/sync/transaction/bank_mutex"
	"sync"
)

func alice(amount int) {
	fmt.Printf("Alice deposit $%d\n", amount)
	bank.Deposit(amount)
}

func bob(amount int) {
	fmt.Printf("Bob deposit $%d\n", amount)
	bank.Deposit(amount)
}

func main() {
	var wg sync.WaitGroup
	wg.Add(2)
	go func() {
		alice(100)
		wg.Done()
	}()
	go func() {
		bob(200)
		wg.Done()
	}()
	wg.Wait()
	fmt.Printf("balance: $%d\n", bank.Balance())

}
